home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / Universal Headers 2.0.1f / OSA.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-22  |  54.5 KB  |  1,601 lines  |  [TEXT/MMCC]

  1. /*
  2.      File:        OSA.h
  3.  
  4.      Contains:    AppleScript Client Interfaces.
  5.  
  6.      Version:    Technology:    AppleScript 1.1
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __OSA__
  21. #define __OSA__
  22.  
  23.  
  24. #ifndef __ERRORS__
  25. #include <Errors.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __APPLEEVENTS__
  30. #include <AppleEvents.h>
  31. #endif
  32. /*    #include <Types.h>                                            */
  33. /*    #include <Memory.h>                                            */
  34. /*        #include <MixedMode.h>                                    */
  35. /*    #include <OSUtils.h>                                        */
  36. /*    #include <Events.h>                                            */
  37. /*        #include <Quickdraw.h>                                    */
  38. /*            #include <QuickdrawText.h>                            */
  39. /*    #include <EPPC.h>                                            */
  40. /*        #include <AppleTalk.h>                                    */
  41. /*        #include <Files.h>                                        */
  42. /*        #include <PPCToolbox.h>                                    */
  43. /*        #include <Processes.h>                                    */
  44. /*    #include <Notification.h>                                    */
  45.  
  46. #ifndef __AEOBJECTS__
  47. #include <AEObjects.h>
  48. #endif
  49.  
  50. #ifndef __COMPONENTS__
  51. #include <Components.h>
  52. #endif
  53.  
  54. #ifdef __cplusplus
  55. extern "C" {
  56. #endif
  57.  
  58. #if PRAGMA_ALIGN_SUPPORTED
  59. #pragma options align=mac68k
  60. #endif
  61.  
  62. #if PRAGMA_IMPORT_SUPPORTED
  63. #pragma import on
  64. #endif
  65.  
  66.  
  67. enum {
  68.     kOSAComponentType            = 'osa '
  69. };
  70.  
  71. /* 0x73637074 */
  72. enum {
  73.     kOSAGenericScriptingComponentSubtype = 'scpt'
  74. };
  75.  
  76. /*    Type of script document files.    */
  77. /* 0x6f736173 */
  78. enum {
  79.     kOSAFileType                = 'osas'
  80. };
  81.  
  82. /*
  83.         Suite and event code of the RecordedText event. 
  84.         (See OSAStartRecording, below.)
  85.     */
  86. /* 0x61736372 */
  87. enum {
  88.     kOSASuite                    = 'ascr'
  89. };
  90.  
  91. /* 0x72656364 */
  92. enum {
  93.     kOSARecordedText            = 'recd'
  94. };
  95.  
  96. /* Selector returns boolean */
  97. /* 0x6d6f6469 */
  98. enum {
  99.     kOSAScriptIsModified        = 'modi'
  100. };
  101.  
  102. /* Selector returns boolean */
  103. /* 0x63736372 */
  104. enum {
  105.     kOSAScriptIsTypeCompiledScript = 'cscr'
  106. };
  107.  
  108. /* Selector returns boolean */
  109. /* 0x76616c75 */
  110. enum {
  111.     kOSAScriptIsTypeScriptValue    = 'valu'
  112. };
  113.  
  114. /* Selector returns boolean */
  115. /* 0x636e7478 */
  116. enum {
  117.     kOSAScriptIsTypeScriptContext = 'cntx'
  118. };
  119.  
  120. /* Selector returns a DescType which may be passed to OSACoerceToDesc */
  121. /* 0x62657374 */
  122. enum {
  123.     kOSAScriptBestType            = 'best'
  124. };
  125.  
  126. /*
  127.         This selector is used to determine whether a script has source 
  128.         associated with it that when given to OSAGetSource, the call will not
  129.         fail.  The selector returns a boolean.
  130.     */
  131. /* 0x67737263 */
  132. enum {
  133.     kOSACanGetSource            = 'gsrc'
  134. };
  135.  
  136. enum {
  137.     typeOSADialectInfo            = 'difo',                        /*  0x6469666f   */
  138.     keyOSADialectName            = 'dnam',                        /*  0x646e616d   */
  139.     keyOSADialectCode            = 'dcod',                        /*  0x64636f64   */
  140.     keyOSADialectLangCode        = 'dlcd',                        /*  0x646c6364   */
  141.     keyOSADialectScriptCode        = 'dscd'
  142. };
  143.  
  144. typedef ComponentResult OSAError;
  145.  
  146. /* Under the Open Scripting Architecture all error results are longs */
  147. typedef unsigned long OSAID;
  148.  
  149. /*
  150.         OSAIDs allow transparent manipulation of scripts associated with
  151.          various scripting systems.
  152.     */
  153.  
  154. enum {
  155.     kOSANullScript                = (OSAID)0
  156. };
  157.  
  158. /* No -script constant. */
  159. enum {
  160.     kOSANullMode                = 0,                            /* sounds better */
  161.     kOSAModeNull                = 0                                /* tastes consistent */
  162. };
  163.  
  164. /*
  165.         Some routines take flags that control their execution.  This constant
  166.         declares default mode settings are used.
  167.     */
  168. typedef pascal OSErr (*OSACreateAppleEventProcPtr)(AEEventClass theAEEventClass, AEEventID theAEEventID, const AEAddressDesc *target, short returnID, long transactionID, AppleEvent *result, long refCon);
  169.  
  170. #if GENERATINGCFM
  171. typedef UniversalProcPtr OSACreateAppleEventUPP;
  172. #else
  173. typedef OSACreateAppleEventProcPtr OSACreateAppleEventUPP;
  174. #endif
  175.  
  176. enum {
  177.     uppOSACreateAppleEventProcInfo = kPascalStackBased
  178.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  179.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(AEEventClass)))
  180.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(AEEventID)))
  181.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(AEAddressDesc*)))
  182.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short)))
  183.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
  184.          | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(AppleEvent*)))
  185.          | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(long)))
  186. };
  187.  
  188. #if GENERATINGCFM
  189. #define NewOSACreateAppleEventProc(userRoutine)        \
  190.         (OSACreateAppleEventUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSACreateAppleEventProcInfo, GetCurrentArchitecture())
  191. #else
  192. #define NewOSACreateAppleEventProc(userRoutine)        \
  193.         ((OSACreateAppleEventUPP) (userRoutine))
  194. #endif
  195.  
  196. #if GENERATINGCFM
  197. #define CallOSACreateAppleEventProc(userRoutine, theAEEventClass, theAEEventID, target, returnID, transactionID, result, refCon)        \
  198.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppOSACreateAppleEventProcInfo, (theAEEventClass), (theAEEventID), (target), (returnID), (transactionID), (result), (refCon))
  199. #else
  200. #define CallOSACreateAppleEventProc(userRoutine, theAEEventClass, theAEEventID, target, returnID, transactionID, result, refCon)        \
  201.         (*(userRoutine))((theAEEventClass), (theAEEventID), (target), (returnID), (transactionID), (result), (refCon))
  202. #endif
  203.  
  204. typedef pascal OSErr (*OSASendProcPtr)(const AppleEvent *theAppleEvent, AppleEvent *reply, AESendMode sendMode, AESendPriority sendPriority, long timeOutInTicks, AEIdleUPP idleProc, AEFilterUPP filterProc, long refCon);
  205.  
  206. #if GENERATINGCFM
  207. typedef UniversalProcPtr OSASendUPP;
  208. #else
  209. typedef OSASendProcPtr OSASendUPP;
  210. #endif
  211.  
  212. enum {
  213.     uppOSASendProcInfo = kPascalStackBased
  214.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  215.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(AppleEvent*)))
  216.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(AppleEvent*)))
  217.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(AESendMode)))
  218.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(AESendPriority)))
  219.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
  220.          | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(AEIdleUPP)))
  221.          | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(AEFilterUPP)))
  222.          | STACK_ROUTINE_PARAMETER(8, SIZE_CODE(sizeof(long)))
  223. };
  224.  
  225. #if GENERATINGCFM
  226. #define NewOSASendProc(userRoutine)        \
  227.         (OSASendUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSASendProcInfo, GetCurrentArchitecture())
  228. #else
  229. #define NewOSASendProc(userRoutine)        \
  230.         ((OSASendUPP) (userRoutine))
  231. #endif
  232.  
  233. #if GENERATINGCFM
  234. #define CallOSASendProc(userRoutine, theAppleEvent, reply, sendMode, sendPriority, timeOutInTicks, idleProc, filterProc, refCon)        \
  235.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppOSASendProcInfo, (theAppleEvent), (reply), (sendMode), (sendPriority), (timeOutInTicks), (idleProc), (filterProc), (refCon))
  236. #else
  237. #define CallOSASendProc(userRoutine, theAppleEvent, reply, sendMode, sendPriority, timeOutInTicks, idleProc, filterProc, refCon)        \
  238.         (*(userRoutine))((theAppleEvent), (reply), (sendMode), (sendPriority), (timeOutInTicks), (idleProc), (filterProc), (refCon))
  239. #endif
  240.  
  241. /**************************************************************************
  242.     Standard Script Errors
  243. **************************************************************************
  244.     It is recommended that scripting components use the following set of error
  245.     codes to signal failure when applicable.  This enables applications that
  246.     use the OSA API to deal with some class of script errors in a less than 
  247.     ad hoc manner.  Scripting components are of course encouraged to return
  248.     component-specific errors when these don't apply.
  249. **************************************************************************/
  250. /*        Dynamic errors:
  251.  
  252.     These errors result from data-dependent conditions and are typically
  253.     signaled at runtime.
  254. */
  255. /*
  256.         Signaled when a value can't be coerced to the desired type. Similar
  257.           to errOSATypeError except results from coercion.
  258.     */
  259. enum {
  260.     errOSACantCoerce            = errAECoercionFail
  261. };
  262.  
  263. /* Signaled when an object is not found in a container */
  264. enum {
  265.     errOSACantAccess            = errAENoSuchObject
  266. };
  267.  
  268. /*
  269.         Signaled when an object cannot be set in a container.  Same as 
  270.           AERegistry error errAEWriteDenied.
  271.     */
  272. enum {
  273.     errOSACantAssign            = -10006
  274. };
  275.  
  276. /*
  277.         Signaled by user scripts or applications when no actual error code
  278.           is to be returned.  Simply means "an error has occurred".  Most useful
  279.           in conjunction with an error message from the application.
  280.     */
  281. enum {
  282.     errOSAGeneralError            = -2700
  283. };
  284.  
  285. /* Signaled when there is an attempt to divide by zero */
  286. enum {
  287.     errOSADivideByZero            = -2701
  288. };
  289.  
  290. /* Signaled when integer or real value is too large to be represented */
  291. enum {
  292.     errOSANumericOverflow        = -2702
  293. };
  294.  
  295. /*
  296.         Signaled when application can't be launched or when it is remote and
  297.           program linking is not enabled.
  298.     */
  299. enum {
  300.     errOSACantLaunch            = -2703
  301. };
  302.  
  303. /* Signaled when an application can't respond to AppleEvents */
  304. enum {
  305.     errOSAAppNotHighLevelEventAware = -2704
  306. };
  307.  
  308. /* Signaled when an application's terminology resource is not readable */
  309. enum {
  310.     errOSACorruptTerminology    = -2705
  311. };
  312.  
  313. /* Signaled when the runtime stack overflows */
  314. enum {
  315.     errOSAStackOverflow            = -2706
  316. };
  317.  
  318. /* Signaled when a runtime internal data structure overflows */
  319. enum {
  320.     errOSAInternalTableOverflow    = -2707
  321. };
  322.  
  323. /*
  324.         Signaled when an intrinsic limitation is exceeded for the size of 
  325.           a value or data structure.
  326.     */
  327. enum {
  328.     errOSADataBlockTooLarge        = -2708
  329. };
  330.  
  331. enum {
  332.     errOSACantGetTerminology    = -2709
  333. };
  334.  
  335. enum {
  336.     errOSACantCreate            = -2710
  337. };
  338.  
  339. /*        Component-specific dynamic script errors:
  340.  
  341.     The range -2720 thru -2739 is reserved for component-specific runtime errors.
  342.     (Note that error codes from different scripting components in this range will
  343.     overlap.)
  344. */
  345. /*        Static errors:
  346.  
  347.     These errors comprise what are commonly thought of as parse and compile-
  348.     time errors.  However, in a dynamic system (e.g. AppleScript) any or all
  349.     of these may also occur at runtime.
  350. */
  351. /* Signaled when data was not the right type and coercion is not allowed */
  352. enum {
  353.     errOSATypeError                = errAEWrongDataType
  354. };
  355.  
  356. /* Signaled when a message was sent to an object that didn't handle it */
  357. enum {
  358.     OSAMessageNotUnderstood        = errAEEventNotHandled
  359. };
  360.  
  361. /*
  362.         Signaled when a function to be returned doesn't exist.  (Probably only
  363.           useful in languages with first-class functions that distinguish between
  364.           functions and other values (two name spaces). This is different from
  365.           errOSAMessageNotUnderstood, which may be signaled when the method is
  366.           invoked.
  367.     */
  368. enum {
  369.     OSAUndefinedHandler            = errAEHandlerNotFound
  370. };
  371.  
  372. /* Signaled when a container can never have the requested object */
  373. enum {
  374.     OSAIllegalAccess            = errAEAccessorNotFound
  375. };
  376.  
  377. /* Signaled when index was out of range. Specialization of errOSACantAccess. */
  378. enum {
  379.     OSAIllegalIndex                = errAEIllegalIndex
  380. };
  381.  
  382. /* Signaled when a range is screwy. Specialization of errOSACantAccess. */
  383. enum {
  384.     OSAIllegalRange                = errAEImpossibleRange
  385. };
  386.  
  387. /*
  388.         Signaled when an object can never be set in a container.  Same as 
  389.           AERegistry error errAENotModifiable.
  390.     */
  391. enum {
  392.     OSAIllegalAssign            = -10003
  393. };
  394.  
  395. /*
  396.         Signaled when a syntax error occurs. (e.g. "Syntax error" or
  397.          "<this> can't go after <that>").
  398.     */
  399. enum {
  400.     OSASyntaxError                = -2740
  401. };
  402.  
  403. /*
  404.         Signaled when another form of syntax was expected. (e.g. "expected
  405.           a <type> but found <this>").
  406.     */
  407. enum {
  408.     OSASyntaxTypeError            = -2741
  409. };
  410.  
  411. /* Signaled when a name or number is too long to be parsed */
  412. enum {
  413.     OSATokenTooLong                = -2742
  414. };
  415.  
  416. /*
  417.         Signaled when a parameter is missing for a function invocation.  Note
  418.           that in some languages, this error may occur at runtime.
  419.     */
  420. enum {
  421.     OSAMissingParameter            = errAEDescNotFound
  422. };
  423.  
  424. /*
  425.         Signaled when function is called with the wrong number of parameters,
  426.           or a parameter pattern cannot be matched.
  427.     */
  428. enum {
  429.     OSAParameterMismatch        = errAEWrongNumberArgs
  430. };
  431.  
  432. /*
  433.         Signaled when a formal parameter, local variable, or instance variable
  434.           is specified more than once.
  435.     */
  436. enum {
  437.     OSADuplicateParameter        = -2750
  438. };
  439.  
  440. /*
  441.         Signaled when a formal parameter, local variable, or instance variable
  442.           is specified more than once.
  443.     */
  444. enum {
  445.     OSADuplicateProperty        = -2751
  446. };
  447.  
  448. /*
  449.         Signaled when more than one handler is defined with the same name in 
  450.           a scope where the language doesn't allow it.
  451.     */
  452. enum {
  453.     OSADuplicateHandler            = -2752
  454. };
  455.  
  456. /* Signaled when a variable is accessed that has no value */
  457. enum {
  458.     OSAUndefinedVariable        = -2753
  459. };
  460.  
  461. /*
  462.         Signaled when a variable is declared inconsistently in the same scope,
  463.           such as both local and global.
  464.     */
  465. enum {
  466.     OSAInconsistentDeclarations    = -2754
  467. };
  468.  
  469. /*
  470.         Signaled when illegal control flow occurs in an application (no catcher
  471.           for throw, non-lexical loop exit, etc.).
  472.     */
  473. enum {
  474.     OSAControlFlowError            = -2755
  475. };
  476.  
  477. /*        Component-specific static script errors:
  478.  
  479.     The range -2760 thru -2779 is reserved for component-specific parsing and
  480.     compile-time errors. (Note that error codes from different scripting
  481.     components in this range will overlap.)
  482. */
  483. /*        Dialect-specific script errors:
  484.  
  485.     The range -2780 thru -2799 is reserved for dialect specific error codes for
  486.     scripting components that support dialects. (Note that error codes from
  487.     different scripting components in this range will overlap, as well as error
  488.     codes from different dialects in the same scripting component.)
  489. */
  490. /**************************************************************************
  491.     OSA Interface Descriptions
  492. **************************************************************************
  493.     The OSA Interface is broken down into a required interface, and several
  494.     optional interfaces to support additional functionality.  A given scripting
  495.     component may choose to support only some of the optional interfaces in
  496.     addition to the basic interface.  The OSA Component Flags may be used to 
  497.     query the Component Manager to find a scripting component with a particular
  498.     capability, or determine if a particular scripting component supports a 
  499.     particular capability.
  500. **************************************************************************/
  501. /* OSA Component Flags: */
  502. enum {
  503.     kOSASupportsCompiling        = 0x0002,
  504.     kOSASupportsGetSource        = 0x0004,
  505.     kOSASupportsAECoercion        = 0x0008,
  506.     kOSASupportsAESending        = 0x0010,
  507.     kOSASupportsRecording        = 0x0020,
  508.     kOSASupportsConvenience        = 0x0040,
  509.     kOSASupportsDialects        = 0x0080,
  510.     kOSASupportsEventHandling    = 0x0100
  511. };
  512.  
  513. /* Component Selectors: */
  514. enum {
  515.     kOSASelectLoad                = 0x0001,
  516.     kOSASelectStore                = 0x0002,
  517.     kOSASelectExecute            = 0x0003,
  518.     kOSASelectDisplay            = 0x0004,
  519.     kOSASelectScriptError        = 0x0005,
  520.     kOSASelectDispose            = 0x0006,
  521.     kOSASelectSetScriptInfo        = 0x0007,
  522.     kOSASelectGetScriptInfo        = 0x0008,
  523.     kOSASelectSetActiveProc        = 0x0009,
  524.     kOSASelectGetActiveProc        = 0x000A
  525. };
  526.  
  527. /* Compiling: */
  528. enum {
  529.     kOSASelectScriptingComponentName = 0x0102,
  530.     kOSASelectCompile            = 0x0103,
  531.     kOSASelectCopyID            = 0x0104
  532. };
  533.  
  534. /* GetSource: */
  535. enum {
  536.     kOSASelectGetSource            = 0x0201
  537. };
  538.  
  539. /* AECoercion: */
  540. enum {
  541.     kOSASelectCoerceFromDesc    = 0x0301,
  542.     kOSASelectCoerceToDesc        = 0x0302
  543. };
  544.  
  545. /* AESending: */
  546. enum {
  547.     kOSASelectSetSendProc        = 0x0401,
  548.     kOSASelectGetSendProc        = 0x0402,
  549.     kOSASelectSetCreateProc        = 0x0403,
  550.     kOSASelectGetCreateProc        = 0x0404,
  551.     kOSASelectSetDefaultTarget    = 0x0405
  552. };
  553.  
  554. /* Recording: */
  555. enum {
  556.     kOSASelectStartRecording    = 0x0501,
  557.     kOSASelectStopRecording        = 0x0502
  558. };
  559.  
  560. /* Convenience: */
  561. enum {
  562.     kOSASelectLoadExecute        = 0x0601,
  563.     kOSASelectCompileExecute    = 0x0602,
  564.     kOSASelectDoScript            = 0x0603
  565. };
  566.  
  567. /* Dialects: */
  568. enum {
  569.     kOSASelectSetCurrentDialect    = 0x0701,
  570.     kOSASelectGetCurrentDialect    = 0x0702,
  571.     kOSASelectAvailableDialects    = 0x0703,
  572.     kOSASelectGetDialectInfo    = 0x0704,
  573.     kOSASelectAvailableDialectCodeList = 0x0705
  574. };
  575.  
  576. /* Event Handling: */
  577. enum {
  578.     kOSASelectSetResumeDispatchProc = 0x0801,
  579.     kOSASelectGetResumeDispatchProc = 0x0802,
  580.     kOSASelectExecuteEvent        = 0x0803,
  581.     kOSASelectDoEvent            = 0x0804,
  582.     kOSASelectMakeContext        = 0x0805
  583. };
  584.  
  585. /* scripting component specific selectors are added beginning with this value  */
  586. enum {
  587.     kOSASelectComponentSpecificStart = 0x1001
  588. };
  589.  
  590. /*        Mode Flags:
  591.  
  592.     Warning: These should not conflict with the AESend mode flags in
  593.     AppleEvents.h, because we may want to use them as OSA mode flags too.
  594. */
  595. /*
  596.         This mode flag may be passed to OSALoad, OSAStore or OSACompile to
  597.           instruct the scripting component to not retain the "source" of an
  598.           expression.  This will cause the OSAGetSource call to return the error
  599.           errOSASourceNotAvailable if used.  However, some scripting components
  600.           may not retain the source anyway.  This is mainly used when either space
  601.           efficiency is desired, or a script is to be "locked" so that its
  602.           implementation may not be viewed.
  603.     */
  604. enum {
  605.     kOSAModePreventGetSource    = 0x00000001
  606. };
  607.  
  608. /*
  609.         These mode flags may be passed to OSACompile, OSAExecute, OSALoadExecute
  610.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  611.           indicate whether or not the script may interact with the user, switch
  612.           layer or reconnect if necessary.  Any AppleEvents will be sent with the
  613.           corresponding AESend mode supplied.
  614.     */
  615. enum {
  616.     kOSAModeNeverInteract        = kAENeverInteract,
  617.     kOSAModeCanInteract            = kAECanInteract,
  618.     kOSAModeAlwaysInteract        = kAEAlwaysInteract,
  619.     kOSAModeDontReconnect        = kAEDontReconnect
  620. };
  621.  
  622. /*
  623.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  624.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  625.           indicate whether or not AppleEvents should be sent with the
  626.           kAECanSwitchLayer mode flag sent or not. NOTE: This flag is exactly the
  627.           opposite sense of the AppleEvent flag kAECanSwitchLayer.  This is to
  628.           provide a more convenient default, i.e. not supplying any mode
  629.           (kOSAModeNull) means to send events with kAECanSwitchLayer.  Supplying
  630.           the kOSAModeCantSwitchLayer mode flag will cause AESend to be called
  631.           without kAECanSwitchLayer.
  632.     */
  633. enum {
  634.     kOSAModeCantSwitchLayer        = 0x00000040
  635. };
  636.  
  637. /*
  638.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  639.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  640.           indicate whether or not AppleEvents should be sent with the kAEDontRecord
  641.           mode flag sent or not. NOTE: This flag is exactly the opposite sense of
  642.           the AppleEvent flag kAEDontRecord.  This is to provide a more convenient
  643.           default, i.e. not supplying any mode (kOSAModeNull) means to send events
  644.           with kAEDontRecord.  Supplying the kOSAModeDoRecord mode flag will 
  645.           cause AESend to be called without kAEDontRecord.
  646.     */
  647. enum {
  648.     kOSAModeDoRecord            = 0x00001000
  649. };
  650.  
  651. /*
  652.         This is a mode flag for OSACompile that indicates that a context should
  653.           be created as the result of compilation. All handler definitions are
  654.           inserted into the new context, and variables are initialized by
  655.           evaluating their initial values in a null context (i.e. they must be
  656.           constant expressions).
  657.     */
  658. enum {
  659.     kOSAModeCompileIntoContext    = 0x00000002
  660. };
  661.  
  662. /*
  663.         This is a mode flag for OSACompile that indicates that the previous
  664.           script ID (input to OSACompile) should be augmented with any new
  665.           definitions in the sourceData rather than replaced with a new script.
  666.           This means that the previous script ID must designate a context.
  667.           The presence of this flag causes the kOSAModeCompileIntoContext flag
  668.           to be implicitly used, causing any new definitions to be initialized
  669.           in a null context.
  670.     */
  671. enum {
  672.     kOSAModeAugmentContext        = 0x00000004
  673. };
  674.  
  675. /*
  676.         This mode flag may be passed to OSADisplay or OSADoScript to indicate
  677.           that output only need be human-readable, not re-compilable by OSACompile.
  678.           If used, output may be arbitrarily "beautified", e.g. quotes may be left
  679.           off of string values, long lists may have elipses, etc.
  680.     */
  681. enum {
  682.     kOSAModeDisplayForHumans    = 0x00000008
  683. };
  684.  
  685. /*
  686.         This mode flag may be passed to OSAStore in the case where the scriptID
  687.           is a context.  This causes the context to be saved, but not the context's
  688.           parent context.  When the stored context is loaded back in, the parent
  689.           will be kOSANullScript.
  690.     */
  691. enum {
  692.     kOSAModeDontStoreParent        = 0x00010000
  693. };
  694.  
  695. /*
  696.         This mode flag may be passed to OSAExecuteEvent to cause the event to
  697.           be dispatched to the direct object of the event. The direct object (or
  698.           subject attribute if the direct object is a non-object specifier) will
  699.           be resolved, and the resulting script object will be the recipient of
  700.           the message. The context argument to OSAExecuteEvent will serve as the
  701.           root of the lookup/resolution process.
  702.     */
  703. enum {
  704.     kOSAModeDispatchToDirectObject = 0x00020000
  705. };
  706.  
  707. /*
  708.         This mode flag may be passed to OSAExecuteEvent to indicate that
  709.           components do not have to get the data of object specifier arguments.
  710.     */
  711. enum {
  712.     kOSAModeDontGetDataForArguments = 0x00040000
  713. };
  714.  
  715. /**************************************************************************
  716.     OSA Basic Scripting Interface
  717. **************************************************************************
  718.     Scripting components must at least support the Basic Scripting interface.
  719. **************************************************************************/
  720. /*        Loading and Storing Scripts:
  721.  
  722.     These routines allow scripts to be loaded and stored in their internal
  723.     (possibly compiled, non-text) representation.
  724. */
  725. /* Resource type for scripts */
  726. enum {
  727.     kOSAScriptResourceType        = kOSAGenericScriptingComponentSubtype
  728. };
  729.  
  730. /*
  731.         Default type given to OSAStore which creates "generic" loadable script
  732.           data descriptors.
  733.     */
  734. enum {
  735.     typeOSAGenericStorage        = kOSAScriptResourceType
  736. };
  737.  
  738. extern pascal OSAError OSALoad(ComponentInstance scriptingComponent, const AEDesc *scriptData, long modeFlags, OSAID *resultingScriptID)
  739.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0001, 0x7000, 0xA82A);
  740. /*
  741.         OSAComponentFunctionInline(kOSASelectLoad, 12);
  742.     
  743.         Errors:
  744.             badComponentInstance        invalid scripting component instance
  745.             errOSASystemError
  746.             errOSABadStorageType:        scriptData not for this scripting component
  747.             errOSACorruptData:            data seems to be corrupt
  748.             errOSADataFormatObsolete    script data format is no longer supported
  749.             errOSADataFormatTooNew        script data format is from a newer version
  750.         
  751.         ModeFlags:
  752.             kOSAModePreventGetSource
  753.     */
  754. extern pascal OSAError OSAStore(ComponentInstance scriptingComponent, OSAID scriptID, DescType desiredType, long modeFlags, AEDesc *resultingScriptData)
  755.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0002, 0x7000, 0xA82A);
  756. /*
  757.         OSAComponentFunctionInline(kOSASelectStore, 16);
  758.     
  759.         Errors:
  760.             badComponentInstance    invalid scripting component instance
  761.             errOSASystemError
  762.             errOSAInvalidID
  763.             errOSABadStorageType:    desiredType not for this scripting component
  764.         
  765.         ModeFlags:
  766.             kOSAModePreventGetSource
  767.             kOSAModeDontStoreParent
  768.     */
  769. /* Executing Scripts: */
  770. extern pascal OSAError OSAExecute(ComponentInstance scriptingComponent, OSAID compiledScriptID, OSAID contextID, long modeFlags, OSAID *resultingScriptValueID)
  771.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0003, 0x7000, 0xA82A);
  772. /*
  773.         OSAComponentFunctionInline(kOSASelectExecute, 16);
  774.         This call runs a script.  The contextID represents the environment
  775.         with which global variables in the script are resolved.  The constant
  776.         kOSANullScript may be used for the contextID if the application wishes
  777.         to not deal with context directly (a default one is associated with each
  778.         scripting component instance).  The resultingScriptValueID is the 
  779.         result of evaluation, and contains a value which may be displayed using
  780.         the OSAGetSource call.  The modeFlags convey scripting component
  781.         specific information.
  782.     
  783.         Errors:
  784.             badComponentInstance    invalid scripting component instance
  785.             errOSASystemError
  786.             errOSAInvalidID
  787.             errOSAScriptError:        the executing script got an error
  788.     
  789.         ModeFlags:
  790.             kOSAModeNeverInteract
  791.             kOSAModeCanInteract
  792.             kOSAModeAlwaysInteract
  793.             kOSAModeCantSwitchLayer
  794.             kOSAModeDontReconnect
  795.             kOSAModeDoRecord
  796.     */
  797. /* Displaying results: */
  798. extern pascal OSAError OSADisplay(ComponentInstance scriptingComponent, OSAID scriptValueID, DescType desiredType, long modeFlags, AEDesc *resultingText)
  799.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0004, 0x7000, 0xA82A);
  800. /*
  801.         OSAComponentFunctionInline(kOSASelectDisplay, 16);
  802.         This call is used to convert results (script value IDs) into displayable
  803.         text. The desiredType should be at least typeChar, and modeFlags are
  804.         scripting system specific flags to control the formatting of the
  805.         resulting text. This call differs from OSAGetSource in that (1) it
  806.         always produces at least typeChar, (2) is only works on script values,
  807.         (3) it may display it's output in non-compilable form (e.g. without
  808.         string quotes, elipses inserted in long and/or circular lists, etc.) and
  809.         (4) it is required by the basic scripting interface.
  810.     
  811.         Errors:
  812.             badComponentInstance    invalid scripting component instance
  813.             errOSASystemError
  814.             errOSAInvalidID
  815.             errAECoercionFail:        desiredType not supported by scripting component
  816.     
  817.         ModeFlags:
  818.             kOSAModeDisplayForHumans
  819.     */
  820. /* Getting Error Information: */
  821. extern pascal OSAError OSAScriptError(ComponentInstance scriptingComponent, OSType selector, DescType desiredType, AEDesc *resultingErrorDescription)
  822.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0005, 0x7000, 0xA82A);
  823. /*
  824.         OSAComponentFunctionInline(kOSASelectScriptError, 12);
  825.         Whenever script execution returns errOSAExecutionError, this routine
  826.         may be used to get information about that error.  The selector describes
  827.         the type of information desired about the error (various selectors are
  828.         listed below).  The desiredType indicates the data type of the result
  829.         desired for that selector.
  830.     
  831.         Errors:
  832.             badComponentInstance    invalid scripting component instance
  833.             errOSASystemError
  834.             errOSABadSelector:        selector not supported by scripting component
  835.             errAECoercionFail:        desiredType not supported by scripting component
  836.     */
  837. /* OSAScriptError selectors: */
  838. /*
  839.         This selector is used to determine the error number of a script error.
  840.         These error numbers may be either system error numbers, or error numbers
  841.         that are scripting component specific.
  842.         Required desiredTypes:    
  843.               typeShortInteger
  844.     */
  845.  
  846. enum {
  847.     kOSAErrorNumber                = keyErrorNumber
  848. };
  849.  
  850. /*
  851.         This selector is used to determine the full error message associated
  852.         with the error number.  It should include the name of the application
  853.         which caused the error, as well as the specific error that occurred.
  854.         This selector is sufficient for simple error reporting (but see
  855.         kOSAErrorBriefMessage, below).
  856.         Required desiredTypes:
  857.             typeChar                    error message string
  858.     */
  859. enum {
  860.     kOSAErrorMessage            = keyErrorString
  861. };
  862.  
  863. /*
  864.         This selector is used to determine a brief error message associated with
  865.         the error number.  This message and should not mention the name of the
  866.         application which caused the error, any partial results or offending
  867.         object (see kOSAErrorApp, kOSAErrorPartialResult and
  868.         kOSAErrorOffendingObject, below).
  869.         Required desiredTypes:
  870.               typeChar                    brief error message string
  871.     */
  872. /*  0x65727262  */
  873. enum {
  874.     kOSAErrorBriefMessage        = 'errb'
  875. };
  876.  
  877. /*
  878.         This selector is used to determine which application actually got the
  879.         error (if it was the result of an AESend), or the current application
  880.         if ....
  881.         Required desiredTypes:
  882.               typeProcessSerialNumber        PSN of the errant application
  883.               typeChar                    name of the errant application
  884.     */
  885. /*  0x65726170  */
  886. enum {
  887.     kOSAErrorApp                = 'erap'
  888. };
  889.  
  890. /*
  891.         This selector is used to determine any partial result returned by an 
  892.         operation. If an AESend call failed, but a partial result was returned,
  893.         then the partial result may be returned as an AEDesc.
  894.         Required desiredTypes:
  895.               typeBest                    AEDesc of any partial result
  896.     */
  897. /*  0x70746c72   */
  898. enum {
  899.     kOSAErrorPartialResult        = 'ptlr'
  900. };
  901.  
  902. /*
  903.         This selector is used to determine any object which caused the error
  904.         that may have been indicated by an application.  The result is an 
  905.         AEDesc.
  906.         Required desiredTypes:
  907.               typeBest                    AEDesc of any offending object
  908.     */
  909. /*  0x65726f62   */
  910. enum {
  911.     kOSAErrorOffendingObject    = 'erob'
  912. };
  913.  
  914. /*
  915.         This selector is used to determine the type expected by a coercion 
  916.         operation if a type error occurred.
  917.     */
  918. /*  0x65727274   */
  919. enum {
  920.     kOSAErrorExpectedType        = 'errt'
  921. };
  922.  
  923. /*
  924.         This selector is used to determine the source text range (start and 
  925.         end positions) of where the error occurred.
  926.         Required desiredTypes:
  927.               typeOSAErrorRange
  928.     */
  929. /*  0x65726e67  */
  930. enum {
  931.     kOSAErrorRange                = 'erng'
  932. };
  933.  
  934. /*
  935.         An AERecord type containing keyOSASourceStart and keyOSASourceEnd fields
  936.         of type short.
  937.     */
  938. /*  0x65726e67   */
  939. enum {
  940.     typeOSAErrorRange            = 'erng'
  941. };
  942.  
  943. /* Field of a typeOSAErrorRange record of typeShortInteger */
  944. /*  0x73726373    */
  945. enum {
  946.     keyOSASourceStart            = 'srcs'
  947. };
  948.  
  949. /* Field of a typeOSAErrorRange record of typeShortInteger */
  950. /*  0x73726365   */
  951. enum {
  952.     keyOSASourceEnd                = 'srce'
  953. };
  954.  
  955. /* Disposing Script IDs: */
  956. extern pascal OSAError OSADispose(ComponentInstance scriptingComponent, OSAID scriptID)
  957.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0006, 0x7000, 0xA82A);
  958. /*
  959.         OSAComponentFunctionInline(kOSASelectDispose, 4);
  960.         Disposes a script or context.
  961.     
  962.         Errors:
  963.             badComponentInstance    invalid scripting component instance
  964.             errOSASystemError
  965.             errOSAInvalidID
  966.     */
  967. /* Getting and Setting Script Information: */
  968. extern pascal OSAError OSASetScriptInfo(ComponentInstance scriptingComponent, OSAID scriptID, OSType selector, long value)
  969.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0007, 0x7000, 0xA82A);
  970. /*
  971.         OSAComponentFunctionInline(kOSASelectSetScriptInfo, 12);
  972.     
  973.         Errors:
  974.             badComponentInstance    invalid scripting component instance
  975.             errOSASystemError
  976.             errOSAInvalidID
  977.             errOSABadSelector:        selector not supported by scripting component
  978.                                     or selector not for this scriptID
  979.     */
  980. extern pascal OSAError OSAGetScriptInfo(ComponentInstance scriptingComponent, OSAID scriptID, OSType selector, long *result)
  981.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0008, 0x7000, 0xA82A);
  982. /*
  983.         OSAComponentFunctionInline(kOSASelectGetScriptInfo, 12);
  984.     
  985.         Errors:
  986.             badComponentInstance    invalid scripting component instance
  987.             errOSASystemError
  988.             errOSAInvalidID
  989.             errOSABadSelector:        selector not supported by scripting component
  990.                                     or selector not for this scriptID
  991.     */
  992. /* Manipulating the ActiveProc:
  993.  
  994.     Scripting systems will supply default values for these procedures if they
  995.     are not set by the client:
  996. */
  997. typedef pascal OSErr (*OSAActiveProcPtr)(long refCon);
  998.  
  999. #if GENERATINGCFM
  1000. typedef UniversalProcPtr OSAActiveUPP;
  1001. #else
  1002. typedef OSAActiveProcPtr OSAActiveUPP;
  1003. #endif
  1004.  
  1005. enum {
  1006.     uppOSAActiveProcInfo = kPascalStackBased
  1007.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  1008.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long)))
  1009. };
  1010.  
  1011. #if GENERATINGCFM
  1012. #define NewOSAActiveProc(userRoutine)        \
  1013.         (OSAActiveUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSAActiveProcInfo, GetCurrentArchitecture())
  1014. #else
  1015. #define NewOSAActiveProc(userRoutine)        \
  1016.         ((OSAActiveUPP) (userRoutine))
  1017. #endif
  1018.  
  1019. #if GENERATINGCFM
  1020. #define CallOSAActiveProc(userRoutine, refCon)        \
  1021.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppOSAActiveProcInfo, (refCon))
  1022. #else
  1023. #define CallOSAActiveProc(userRoutine, refCon)        \
  1024.         (*(userRoutine))((refCon))
  1025. #endif
  1026.  
  1027. extern pascal OSAError OSASetActiveProc(ComponentInstance scriptingComponent, OSAActiveUPP activeProc, long refCon)
  1028.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0009, 0x7000, 0xA82A);
  1029. /*
  1030.         OSAComponentFunctionInline(kOSASelectSetActiveProc, 8);
  1031.         If activeProc is nil, the default activeProc is used.
  1032.     
  1033.         Errors:
  1034.             badComponentInstance    invalid scripting component instance
  1035.             errOSASystemError
  1036.     */
  1037. extern pascal OSAError OSAGetActiveProc(ComponentInstance scriptingComponent, OSAActiveUPP *activeProc, long *refCon)
  1038.  FIVEWORDINLINE(0x2F3C, 0x8, 0x000A, 0x7000, 0xA82A);
  1039. /*
  1040.         OSAComponentFunctionInline(kOSASelectGetActiveProc, 8);
  1041.     
  1042.         Errors:
  1043.             badComponentInstance    invalid scripting component instance
  1044.             errOSASystemError
  1045.     */
  1046. /**************************************************************************
  1047.     OSA Optional Compiling Interface
  1048. **************************************************************************
  1049.     Scripting components that support the Compiling interface have the 
  1050.     kOSASupportsCompiling bit set in it's ComponentDescription.
  1051. **************************************************************************/
  1052. extern pascal OSAError OSAScriptingComponentName(ComponentInstance scriptingComponent, AEDesc *resultingScriptingComponentName)
  1053.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0102, 0x7000, 0xA82A);
  1054. /*
  1055.         OSAComponentFunctionInline(kOSASelectScriptingComponentName, 4);
  1056.         Given a scripting component, this routine returns the name of that
  1057.         scripting component in a type that is coercable to text (typeChar).
  1058.         The generic scripting component returns the name of the default
  1059.         scripting component.  This name should be sufficient to convey to the
  1060.         user the kind of script (syntax) he is expected to write.
  1061.     
  1062.         Errors:
  1063.             badComponentInstance    invalid scripting component instance
  1064.             errOSASystemError
  1065.     */
  1066. extern pascal OSAError OSACompile(ComponentInstance scriptingComponent, const AEDesc *sourceData, long modeFlags, OSAID *previousAndResultingScriptID)
  1067.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0103, 0x7000, 0xA82A);
  1068. /*
  1069.         OSAComponentFunctionInline(kOSASelectCompile, 12);
  1070.         Coerces input desc (possibly text) into a script's internal format.
  1071.         Once compiled, the script is ready to run.  The modeFlags convey
  1072.         scripting component specific information.  The previous script ID
  1073.         (result parameter) is made to refer to the newly compiled script,
  1074.         unless it was originally kOSANullScript.  In this case a new script
  1075.         ID is created and used.
  1076.     
  1077.         Errors:
  1078.             badComponentInstance    invalid scripting component instance
  1079.             errOSASystemError
  1080.             errAECoercionFail:        sourceData is not compilable
  1081.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1082.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1083.                                     valid on input
  1084.     
  1085.         ModeFlags:
  1086.             kOSAModePreventGetSource
  1087.             kOSAModeCompileIntoContext
  1088.             kOSAModeAugmentContext
  1089.             kOSAModeNeverInteract
  1090.             kOSAModeCanInteract
  1091.             kOSAModeAlwaysInteract
  1092.             kOSAModeCantSwitchLayer
  1093.             kOSAModeDontReconnect
  1094.             kOSAModeDoRecord
  1095.     */
  1096. extern pascal OSAError OSACopyID(ComponentInstance scriptingComponent, OSAID fromID, OSAID *toID)
  1097.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0104, 0x7000, 0xA82A);
  1098. /*
  1099.         OSAComponentFunctionInline(kOSASelectCopyID, 8);
  1100.         If toID is a reference to kOSANullScript then it is updated to have a
  1101.         new scriptID value.  This call can be used to perform undo or revert
  1102.         operations on scripts. 
  1103.     
  1104.         Errors:
  1105.             badComponentInstance    invalid scripting component instance
  1106.             errOSASystemError
  1107.             errOSAInvalidID
  1108.     */
  1109. /**************************************************************************
  1110.     OSA Optional GetSource Interface
  1111. **************************************************************************
  1112.     Scripting components that support the GetSource interface have the 
  1113.     kOSASupportsGetSource bit set in it's ComponentDescription.
  1114. **************************************************************************/
  1115. extern pascal OSAError OSAGetSource(ComponentInstance scriptingComponent, OSAID scriptID, DescType desiredType, AEDesc *resultingSourceData)
  1116.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0201, 0x7000, 0xA82A);
  1117. /*
  1118.         OSAComponentFunctionInline(kOSASelectGetSource, 12);
  1119.         This routine causes a compiled script to be output in a form (possibly
  1120.         text) such that it is suitable to be passed back to OSACompile.
  1121.  
  1122.         Errors:
  1123.             badComponentInstance    invalid scripting component instance
  1124.             errOSASystemError
  1125.             errOSAInvalidID
  1126.             errOSASourceNotAvailable    can't get source for this scriptID
  1127.     */
  1128. /**************************************************************************
  1129.     OSA Optional AECoercion Interface
  1130. **************************************************************************
  1131.     Scripting components that support the AECoercion interface have the 
  1132.     kOSASupportsAECoercion bit set in it's ComponentDescription.
  1133. **************************************************************************/
  1134. extern pascal OSAError OSACoerceFromDesc(ComponentInstance scriptingComponent, const AEDesc *scriptData, long modeFlags, OSAID *resultingScriptID)
  1135.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0301, 0x7000, 0xA82A);
  1136. /*
  1137.         OSAComponentFunctionInline(kOSASelectCoerceFromDesc, 12);
  1138.         This routine causes script data to be coerced into a script value.
  1139.         If the scriptData is an AppleEvent, then the resultingScriptID is a
  1140.         compiled script ID (mode flags for OSACompile may be used in this case).
  1141.         Other scriptData descriptors create script value IDs.
  1142.     
  1143.         Errors:
  1144.             badComponentInstance    invalid scripting component instance
  1145.             errOSASystemError
  1146.     
  1147.         ModeFlags:
  1148.             kOSAModePreventGetSource
  1149.             kOSAModeCompileIntoContext
  1150.             kOSAModeNeverInteract
  1151.             kOSAModeCanInteract
  1152.             kOSAModeAlwaysInteract
  1153.             kOSAModeCantSwitchLayer
  1154.             kOSAModeDontReconnect
  1155.             kOSAModeDoRecord
  1156.     */
  1157. extern pascal OSAError OSACoerceToDesc(ComponentInstance scriptingComponent, OSAID scriptID, DescType desiredType, long modeFlags, AEDesc *result)
  1158.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0302, 0x7000, 0xA82A);
  1159. /*
  1160.         OSAComponentFunctionInline(kOSASelectCoerceToDesc, 16);
  1161.         This routine causes a script value to be coerced into any desired form.
  1162.         If the scriptID denotes a compiled script, then it may be coerced to 
  1163.         typeAppleEvent.
  1164.     
  1165.         Errors:
  1166.             badComponentInstance    invalid scripting component instance
  1167.             errOSASystemError
  1168.             errOSAInvalidID
  1169.     */
  1170. /**************************************************************************
  1171.     OSA Optional AESending Interface
  1172. **************************************************************************
  1173.     Scripting components that support the AESending interface have the 
  1174.     kOSASupportsAESending bit set in it's ComponentDescription.
  1175. **************************************************************************/
  1176. /*
  1177.     Scripting systems will supply default values for these procedures if they
  1178.     are not set by the client:
  1179. */
  1180. extern pascal OSAError OSASetSendProc(ComponentInstance scriptingComponent, OSASendUPP sendProc, long refCon)
  1181.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0401, 0x7000, 0xA82A);
  1182. /*
  1183.         OSAComponentFunctionInline(kOSASelectSetSendProc, 8);
  1184.         If sendProc is nil, the default sendProc is used.
  1185.     
  1186.         Errors:
  1187.             badComponentInstance    invalid scripting component instance
  1188.             errOSASystemError
  1189.     */
  1190. extern pascal OSAError OSAGetSendProc(ComponentInstance scriptingComponent, OSASendUPP *sendProc, long *refCon)
  1191.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0402, 0x7000, 0xA82A);
  1192. /*
  1193.         OSAComponentFunctionInline(kOSASelectGetSendProc, 8);
  1194.     
  1195.         Errors:
  1196.             badComponentInstance    invalid scripting component instance
  1197.             errOSASystemError
  1198.     */
  1199. extern pascal OSAError OSASetCreateProc(ComponentInstance scriptingComponent, OSACreateAppleEventUPP createProc, long refCon)
  1200.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0403, 0x7000, 0xA82A);
  1201. /*
  1202.         OSAComponentFunctionInline(kOSASelectSetCreateProc, 8);
  1203.         If createProc is nil, the default createProc is used.
  1204.     
  1205.         Errors:
  1206.             badComponentInstance    invalid scripting component instance
  1207.             errOSASystemError
  1208.     */
  1209. extern pascal OSAError OSAGetCreateProc(ComponentInstance scriptingComponent, OSACreateAppleEventUPP *createProc, long *refCon)
  1210.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0404, 0x7000, 0xA82A);
  1211. /*
  1212.         OSAComponentFunctionInline(kOSASelectGetCreateProc, 8);
  1213.     
  1214.         Errors:
  1215.             badComponentInstance    invalid scripting component instance
  1216.             errOSASystemError
  1217.     */
  1218. extern pascal OSAError OSASetDefaultTarget(ComponentInstance scriptingComponent, const AEAddressDesc *target)
  1219.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0405, 0x7000, 0xA82A);
  1220. /*
  1221.         OSAComponentFunctionInline(kOSASelectSetDefaultTarget, 4);
  1222.         This routine sets the default target application for AE sending.
  1223.         It also establishes the default target from which terminologies come.
  1224.         It is effectively like having an AppleScript "tell" statement around
  1225.         the entire program.  If this routine is not called, or if the target 
  1226.         is a null AEDesc, then the current application is the default target.
  1227.     
  1228.         Errors:
  1229.             badComponentInstance    invalid scripting component instance
  1230.             errOSASystemError
  1231.     */
  1232. /**************************************************************************
  1233.     OSA Optional Recording Interface
  1234. **************************************************************************
  1235.     Scripting components that support the Recording interface have the 
  1236.     kOSASupportsRecording bit set in it's ComponentDescription.
  1237. **************************************************************************/
  1238. extern pascal OSAError OSAStartRecording(ComponentInstance scriptingComponent, OSAID *compiledScriptToModifyID)
  1239.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0501, 0x7000, 0xA82A);
  1240. /*
  1241.         OSAComponentFunctionInline(kOSASelectStartRecording, 4);
  1242.         Starts recording.  If compiledScriptToModifyID is kOSANullScript, a
  1243.         new script ID is created and returned.  If the current application has
  1244.         a handler for the kOSARecordedText event, then kOSARecordedText events
  1245.         are sent to the application containing the text of each AppleEvent 
  1246.         recorded.
  1247.     
  1248.         Errors:
  1249.             badComponentInstance    invalid scripting component instance
  1250.             errOSASystemError
  1251.             errOSAInvalidID
  1252.             errOSARecordingIsAlreadyOn
  1253.     */
  1254. extern pascal OSAError OSAStopRecording(ComponentInstance scriptingComponent, OSAID compiledScriptID)
  1255.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0502, 0x7000, 0xA82A);
  1256. /*
  1257.         OSAComponentFunctionInline(kOSASelectStopRecording, 4);
  1258.         If compiledScriptID is not being recorded into or recording is not
  1259.         currently on, no error is returned.
  1260.     
  1261.         Errors:
  1262.             badComponentInstance    invalid scripting component instance
  1263.             errOSASystemError
  1264.             errOSAInvalidID
  1265.     */
  1266. /**************************************************************************
  1267.     OSA Optional Convenience Interface
  1268. **************************************************************************
  1269.     Scripting components that support the Convenience interface have the 
  1270.     kOSASupportsConvenience bit set in it's ComponentDescription.
  1271. **************************************************************************/
  1272. extern pascal OSAError OSALoadExecute(ComponentInstance scriptingComponent, const AEDesc *scriptData, OSAID contextID, long modeFlags, OSAID *resultingScriptValueID)
  1273.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0601, 0x7000, 0xA82A);
  1274. /*
  1275.         OSAComponentFunctionInline(kOSASelectLoadExecute, 16);
  1276.         This routine is effectively equivalent to calling OSALoad followed by
  1277.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1278.         resulting value ID is retained.
  1279.     
  1280.         Errors:
  1281.             badComponentInstance        invalid scripting component instance
  1282.             errOSASystemError
  1283.             errOSABadStorageType:        scriptData not for this scripting component
  1284.             errOSACorruptData:            data seems to be corrupt
  1285.             errOSADataFormatObsolete    script data format is no longer supported
  1286.             errOSADataFormatTooNew        script data format is from a newer version
  1287.             errOSAInvalidID
  1288.             errOSAScriptError:            the executing script got an error
  1289.     
  1290.         ModeFlags:
  1291.             kOSAModeNeverInteract
  1292.             kOSAModeCanInteract
  1293.             kOSAModeAlwaysInteract
  1294.             kOSAModeCantSwitchLayer
  1295.             kOSAModeDontReconnect
  1296.             kOSAModeDoRecord
  1297.     */
  1298. extern pascal OSAError OSACompileExecute(ComponentInstance scriptingComponent, const AEDesc *sourceData, OSAID contextID, long modeFlags, OSAID *resultingScriptValueID)
  1299.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0602, 0x7000, 0xA82A);
  1300. /*
  1301.         OSAComponentFunctionInline(kOSASelectCompileExecute, 16);
  1302.         This routine is effectively equivalent to calling OSACompile followed by
  1303.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1304.         resulting value ID is retained.
  1305.     
  1306.         Errors:
  1307.             badComponentInstance    invalid scripting component instance
  1308.             errOSASystemError
  1309.             errAECoercionFail:        sourceData is not compilable
  1310.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1311.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1312.                                     valid on input
  1313.             errOSAScriptError:        the executing script got an error
  1314.     
  1315.         ModeFlags:
  1316.             kOSAModeNeverInteract
  1317.             kOSAModeCanInteract
  1318.             kOSAModeAlwaysInteract
  1319.             kOSAModeCantSwitchLayer
  1320.             kOSAModeDontReconnect
  1321.             kOSAModeDoRecord
  1322.     */
  1323. extern pascal OSAError OSADoScript(ComponentInstance scriptingComponent, const AEDesc *sourceData, OSAID contextID, DescType desiredType, long modeFlags, AEDesc *resultingText)
  1324.  FIVEWORDINLINE(0x2F3C, 0x14, 0x0603, 0x7000, 0xA82A);
  1325. /*
  1326.         OSAComponentFunctionInline(kOSASelectDoScript, 20);
  1327.         This routine is effectively equivalent to calling OSACompile followed by
  1328.         OSAExecute and then OSADisplay.  After execution, the compiled source
  1329.         and the resulting value are is disposed.  Only the resultingText
  1330.         descriptor is retained.  If a script error occur during processing, the 
  1331.         resultingText gets the error message of the error, and errOSAScriptError
  1332.         is returned.  OSAScriptError may still be used to extract more 
  1333.         information about the particular error.
  1334.     
  1335.         Errors:
  1336.             badComponentInstance    invalid scripting component instance
  1337.             errOSASystemError
  1338.             errAECoercionFail:        sourceData is not compilable or 
  1339.                                     desiredType not supported by scripting component
  1340.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1341.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1342.                                     valid on input
  1343.             errOSAScriptError:        the executing script got an error
  1344.     
  1345.         ModeFlags:
  1346.             kOSAModeNeverInteract
  1347.             kOSAModeCanInteract
  1348.             kOSAModeAlwaysInteract
  1349.             kOSAModeCantSwitchLayer
  1350.             kOSAModeDontReconnect
  1351.             kOSAModeDoRecord
  1352.             kOSAModeDisplayForHumans
  1353.     */
  1354. /**************************************************************************
  1355.     OSA Optional Dialects Interface
  1356. **************************************************************************
  1357.     Scripting components that support the Dialects interface have the 
  1358.     kOSASupportsDialects bit set in it's ComponentDescription.
  1359. **************************************************************************/
  1360. /*
  1361.     These calls allows an scripting component that supports different dialects
  1362.     to dynamically switch between those dialects.  Although this interface is
  1363.     specified, the particular dialect codes are scripting component dependent.
  1364. */
  1365. extern pascal OSAError OSASetCurrentDialect(ComponentInstance scriptingComponent, short dialectCode)
  1366.  FIVEWORDINLINE(0x2F3C, 0x2, 0x0701, 0x7000, 0xA82A);
  1367. /*
  1368.         OSAComponentFunctionInline(kOSASelectSetCurrentDialect, 2);
  1369.     
  1370.         Errors:
  1371.             badComponentInstance    invalid scripting component instance
  1372.             errOSASystemError
  1373.             errOSANoSuchDialect:    invalid dialectCode
  1374.     */
  1375. extern pascal OSAError OSAGetCurrentDialect(ComponentInstance scriptingComponent, short *resultingDialectCode)
  1376.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0702, 0x7000, 0xA82A);
  1377. /*
  1378.         OSAComponentFunctionInline(kOSASelectGetCurrentDialect, 4);
  1379.     
  1380.         Errors:
  1381.             badComponentInstance    invalid scripting component instance
  1382.             errOSASystemError
  1383.     */
  1384. extern pascal OSAError OSAAvailableDialects(ComponentInstance scriptingComponent, AEDesc *resultingDialectInfoList)
  1385.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0703, 0x7000, 0xA82A);
  1386. /*
  1387.         OSAComponentFunctionInline(kOSASelectAvailableDialects, 4);
  1388.         This call return an AEList containing information about each of the
  1389.         currently available dialects of a scripting component.  Each item
  1390.         is an AERecord of typeOSADialectInfo that contains at least the fields
  1391.         keyOSADialectName, keyOSADialectCode, KeyOSADialectLangCode and 
  1392.         keyOSADialectScriptCode.
  1393.     
  1394.         Errors:
  1395.             badComponentInstance    invalid scripting component instance
  1396.             errOSASystemError
  1397.     */
  1398. extern pascal OSAError OSAGetDialectInfo(ComponentInstance scriptingComponent, short dialectCode, OSType selector, AEDesc *resultingDialectInfo)
  1399.  FIVEWORDINLINE(0x2F3C, 0xA, 0x0704, 0x7000, 0xA82A);
  1400. /*
  1401.         OSAComponentFunctionInline(kOSASelectGetDialectInfo, 10);
  1402.         This call gives information about the specified dialect of a scripting
  1403.         component. It returns an AEDesc whose type depends on the selector 
  1404.         specified. Available selectors are the same as the field keys for a
  1405.         dialect info record. The type of AEDesc returned is the same as the 
  1406.         type of the field that has same key as the selector.
  1407.     
  1408.         Errors:
  1409.             badComponentInstance    invalid scripting component instance
  1410.             errOSASystemError
  1411.              errOSABadSelector
  1412.             errOSANoSuchDialect:    invalid dialectCode
  1413.     */
  1414. extern pascal OSAError OSAAvailableDialectCodeList(ComponentInstance scriptingComponent, AEDesc *resultingDialectCodeList)
  1415.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0705, 0x7000, 0xA82A);
  1416. /*
  1417.         OSAComponentFunctionInline(kOSASelectAvailableDialectCodeList, 4);
  1418.         This is alternative to OSAGetAvailableDialectCodeList. Use this call
  1419.         and  OSAGetDialectInfo to get information on dialects.
  1420.         This call return an AEList containing dialect code for each of the
  1421.         currently available dialects of a scripting component. Each dialect
  1422.         code is a short integer of type typeShortInteger.
  1423.     
  1424.         Errors:
  1425.             badComponentInstance    invalid scripting component instance
  1426.             errOSASystemError
  1427.  
  1428.         Type of a dialect info record containing at least keyOSADialectName
  1429.         and keyOSADialectCode fields.
  1430.  
  1431.         keys for dialect info record, also used as selectors to OSAGetDialectInfo.
  1432.  
  1433.         Field of a typeOSADialectInfo record of typeChar.
  1434.         Field of a typeOSADialectInfo record of typeShortInteger.
  1435.         Field of a typeOSADialectInfo record of typeShortInteger.
  1436.         Field of a typeOSADialectInfo record of typeShortInteger.
  1437.     */
  1438. /**************************************************************************
  1439.     OSA Optional Event Handling Interface
  1440. **************************************************************************
  1441.     Scripting components that support the Event Handling interface have the 
  1442.     kOSASupportsEventHandling bit set in it's ComponentDescription.
  1443. **************************************************************************/
  1444. extern pascal OSAError OSASetResumeDispatchProc(ComponentInstance scriptingComponent, AEEventHandlerUPP resumeDispatchProc, long refCon)
  1445.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0801, 0x7000, 0xA82A);
  1446. /*
  1447.         OSAComponentFunctionInline(kOSASelectSetResumeDispatchProc, 8);
  1448.         This function is used to set the ResumeDispatchProc that will be used
  1449.         by OSAExecuteEvent and OSADoEvent if either no event handler can be
  1450.         found in the context, or the context event hander "continues" control
  1451.         onward. The two constants kOSAUseStandardDispatch and kOSANoDispatch
  1452.         may also be passed to this routine indicating that the handler registered
  1453.         in the application with AEInstallEventHandler should be used, or no
  1454.         dispatch should occur, respectively.
  1455.     
  1456.         Errors:
  1457.             badComponentInstance    invalid scripting component instance
  1458.             errOSASystemError
  1459.     */
  1460.  
  1461. enum {
  1462.     kOSAUseStandardDispatch        = kAEUseStandardDispatch
  1463. };
  1464.  
  1465. /*
  1466.         Special ResumeDispatchProc constant which may be passed to 
  1467.         OSASetResumeDispatchProc indicating that the handler registered
  1468.         in the application with AEInstallEventHandler should be used.
  1469.         
  1470.         NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1471.                 doesn't allow pointer types to be assigned to an enum.  All
  1472.                 constants must be assigned as enums to translate properly to
  1473.                 Pascal.
  1474.     */
  1475. enum {
  1476.     kOSANoDispatch                = kAENoDispatch
  1477. };
  1478.  
  1479. /*
  1480.         Special ResumeDispatchProc constant which may be passed to 
  1481.         OSASetResumeDispatchProc indicating that no dispatch should occur.
  1482.         
  1483.         NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1484.                 doesn't allow pointer types to be assigned to an enum.  All
  1485.                 constants must be assigned as enums to translate properly to
  1486.                 Pascal.
  1487.     */
  1488. enum {
  1489.     kOSADontUsePhac                = 0x0001
  1490. };
  1491.  
  1492. /*
  1493.         Special refCon constant that may be given to OSASetResumeDispatchProc
  1494.         only when kOSAUseStandardDispatch is used as the ResumeDispatchProc.
  1495.         This causes the standard dispatch to be performed, except the phac
  1496.         handler is not called.  This is useful during tinkerability, when
  1497.         the phac handler is used to lookup a context associated with an event's 
  1498.         direct parameter, and call OSAExecuteEvent or OSADoEvent.  Failure to
  1499.         bypass the phac handler would result in an infinite loop.
  1500.     */
  1501. extern pascal OSAError OSAGetResumeDispatchProc(ComponentInstance scriptingComponent, AEEventHandlerUPP *resumeDispatchProc, long *refCon)
  1502.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0802, 0x7000, 0xA82A);
  1503. /*
  1504.         OSAComponentFunctionInline(kOSASelectGetResumeDispatchProc, 8);
  1505.         Returns the registered ResumeDispatchProc.  If no ResumeDispatchProc has
  1506.         been registered, then kOSAUseStandardDispatch (the default) is returned.
  1507.     
  1508.         Errors:
  1509.             badComponentInstance    invalid scripting component instance
  1510.             errOSASystemError
  1511.     */
  1512. extern pascal OSAError OSAExecuteEvent(ComponentInstance scriptingComponent, const AppleEvent *theAppleEvent, OSAID contextID, long modeFlags, OSAID *resultingScriptValueID)
  1513.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0803, 0x7000, 0xA82A);
  1514. /*
  1515.         OSAComponentFunctionInline(kOSASelectExecuteEvent, 16);
  1516.         This call is similar to OSAExecute except the initial command to
  1517.         execute comes in the form of an AppleEvent.  If the contextID
  1518.         defines any event handlers for that event, they are used to process
  1519.         the event.  If no event handler can be found in the context
  1520.         errAEEventNotHandled is returned.  If an event handler is found and
  1521.         the hander "continues" control onward, the ResumeDispatchProc
  1522.         (registered with OSASetResumeDispatchProc, above) is called given the
  1523.         AppleEvent.  The result is returned as a scriptValueID.
  1524.     
  1525.         Errors:
  1526.             badComponentInstance    invalid scripting component instance
  1527.             errOSASystemError
  1528.             errOSAInvalidID
  1529.             errOSAScriptError:        the executing script got an error
  1530.             errAEEventNotHandled:    no handler for event in contextID
  1531.     
  1532.         ModeFlags:
  1533.             kOSAModeNeverInteract
  1534.             kOSAModeCanInteract
  1535.             kOSAModeAlwaysInteract
  1536.             kOSAModeCantSwitchLayer
  1537.             kOSAModeDontReconnect
  1538.             kOSAModeDoRecord
  1539.     */
  1540. extern pascal OSAError OSADoEvent(ComponentInstance scriptingComponent, const AppleEvent *theAppleEvent, OSAID contextID, long modeFlags, AppleEvent *reply)
  1541.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0804, 0x7000, 0xA82A);
  1542. /*
  1543.         OSAComponentFunctionInline(kOSASelectDoEvent, 16);
  1544.         This call is similar to OSADoScript except the initial command to
  1545.         execute comes in the form of an AppleEvent, and the result is an 
  1546.         AppleEvent reply record.  If the contextID defines any event handlers
  1547.         for that event, they are used to process the event.  If no event handler
  1548.         can be found in the context errAEEventNotHandled is returned.  If an
  1549.         event handler is found and the hander "continues" control onward, the
  1550.         ResumeDispatchProc (registered with OSASetResumeDispatchProc, above) is
  1551.         called given the AppleEvent.  The result is returned in the form of an
  1552.         AppleEvent reply descriptor. If at any time the script gets an error, or
  1553.         if the ResumeDispatchProc returns a reply event indicating an error,
  1554.         then the OSADoEvent call itself returns an error reply (i.e. OSADoEvent
  1555.         should never return errOSAScriptError).  Any error result returned by
  1556.         the ResumeDispatchProc will be returned by OSADoEvent.
  1557.     
  1558.         Errors:
  1559.             badComponentInstance    invalid scripting component instance
  1560.             errOSASystemError
  1561.             errOSAInvalidID
  1562.             errAEEventNotHandled:    no handler for event in contextID
  1563.     
  1564.         ModeFlags:
  1565.             kOSAModeNeverInteract
  1566.             kOSAModeCanInteract
  1567.             kOSAModeAlwaysInteract
  1568.             kOSAModeCantSwitchLayer
  1569.             kOSAModeDontReconnect
  1570.             kOSAModeDoRecord
  1571.     */
  1572. extern pascal OSAError OSAMakeContext(ComponentInstance scriptingComponent, const AEDesc *contextName, OSAID parentContext, OSAID *resultingContextID)
  1573.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0805, 0x7000, 0xA82A);
  1574. /*
  1575.         OSAComponentFunctionInline(kOSASelectMakeContext, 12);
  1576.         Makes a new empty context which may be passed to OSAExecute or 
  1577.         OSAExecuteEvent.  If contextName is typeNull, an unnamed context is
  1578.         created. If parentContext is kOSANullScript then the resulting context
  1579.         does not inherit bindings from any other context.
  1580.     
  1581.         Errors:
  1582.             badComponentInstance    invalid scripting component instance
  1583.             errOSASystemError
  1584.             errOSAInvalidID
  1585.             errAECoercionFail:        contextName is invalid
  1586.     */
  1587.  
  1588. #if PRAGMA_IMPORT_SUPPORTED
  1589. #pragma import off
  1590. #endif
  1591.  
  1592. #if PRAGMA_ALIGN_SUPPORTED
  1593. #pragma options align=reset
  1594. #endif
  1595.  
  1596. #ifdef __cplusplus
  1597. }
  1598. #endif
  1599.  
  1600. #endif /* __OSA__ */
  1601.